package xyz.riceball.job.listener;

import org.quartz.JobDataMap;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.listeners.JobListenerSupport;

/**
 * <p>
 * 任务执行前后调用
 * </p>
 *
 * @author xiaovcloud
 * @since 2022/6/16 21:06
 */
public class RbJobListener extends JobListenerSupport {


    @Override
    public String getName() {
        return "RbJobListener";
    }

    @Override
    public void jobToBeExecuted(JobExecutionContext context) {
        JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
        getLog().info(jobDataMap.get("message") + ", 1");
    }

    @Override
    public void jobExecutionVetoed(JobExecutionContext context) {
        JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
        getLog().info(jobDataMap.get("message") + ", 2");
    }

    @Override
    public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
        JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
        getLog().info(jobDataMap.get("message") + ", 3");
    }
}
